package playbook

//go:generate msgp

const (
	DefaultGroup = 0
)

type MakeRelation byte

const (
	BaseMake        MakeRelation = 0
	PlayerMake                   = 1
	OtherPlayerMake              = 2
	AiMake                       = 3
	AiPlayerMake                 = 4
)

type InfoKey byte

const (
	TargetKey InfoKey = iota
	// 服务器信息
	ServerKey
	// 地图信息
	MapKey
	// 等待客户端confirm
	Wait
	// 客户端返回confirm
	Confirm
	// 创建对象
	MakeKey
	// 关联id
	RelationKey
	// 道具统计项
	ObjectDataKey
	// 怪物统计项
	TargetDataKey
	// 任务信息
	TaskKey
	// 下发任务进度
	TaskProcessKey
	// 身份信息
	IdentityKey
	// ui显示信息
	UiKey
	// Data数据
	DataKey
	// 固定地图
	OpenMapKey
	// 指定Master
	MasterKey
)

const (
	TargetMake byte = iota
	ObjectMake
)

//msgp:tuple MakeInfo
type MakeInfo struct {
	Id       int          `json:"id" msg:"id"`
	Category byte         `json:"category" msg:"category"`
	Relation MakeRelation `json:"relation" msg:"relation"`
	X        float32      `json:"x" msg:"x"`
	Y        float32      `json:"y" msg:"y"`
	Z        float32      `json:"z" msg:"z"`
}

//msgp:tuple InfoDetail
type InfoDetail struct {
	Key   InfoKey     `json:"key" msg:"key"`
	Value interface{} `json:"value" msg:"value"`

	// 用于处理需要多语言下发的信息, 按playbook的languages顺序
	language []interface{}
}

func (info *InfoDetail) Language(language []interface{}) *InfoDetail {
	info.language = language
	return info
}

type InfoArray []InfoDetail

//msgp:tuple TaskDetail
type TaskDetail struct {
	Ids       []int `json:"ids" msg:"ids"`
	DataIndex []int `json:"dataIndex" msg:"dataIndex"`
}

//msgp:tuple TaskProcess
type TaskProcess struct {
	Id      int   `json:"id" msg:"id"`
	Process int32 `json:"process" msg:"process"`
}

//msgp:tuple SafeRegion
type SafeRegion struct {
	Radius int     `json:"radius" msg:"radius"`
	X      float32 `json:"x" msg:"x"`
	Y      float32 `json:"y" msg:"y"`
	Z      float32 `json:"z" msg:"z"`
}

//msgp:tuple MapInfo
type MapInfo struct {
	Number int `json:"number" msg:"number"`
	Random int `json:"random" msg:"random"`
	Type   int `json:"type" msg:"type"`
	X      int `json:"x" msg:"x"`
	Y      int `json:"y" msg:"y"`
}

//msgp:tuple ServerInfo
type ServerInfo struct {
	Start int `json:"start" msg:"start"`
}

//msgp:tuple ProcessDetail
type ProcessDetail struct {
	Id     int    `json:"id" msg:"id"`
	Detail string `json:"detail" msg:"detail"`
}

//msgp:tuple UiInfo
type UiInfo struct {
	Event byte `json:"event" msg:"event"`
	Key   byte `json:"key" msg:"key"`
	Value int  `json:"value" msg:"value"`
}

const (
	ModeUiKey byte = iota
	NumberUiKey
)
